#pragma once

#include "Arduino.h"
#include "u8g2.hpp"


using TimeType = uint32_t;

class TimeCycle {
   private:
    TimeType _last_time = 0;

   public:
    TimeCycle() = default;

    bool cycle(TimeType interval) {
        TimeType current_time = millis();
        if (current_time - _last_time >= interval) {
            _last_time = current_time;
            return true;
        }
        return false;
    }


    bool expired(TimeType interval) const {
        TimeType current_time = millis();
        return (current_time - _last_time >= interval);
    }


    void reset() {
        _last_time = millis();
    }
};
